<?php 
session_start();
$active = 'community';


//if(!isset($_SESSION['username']) || !isset($_SESSION['id']))
//{
//	header("Location: require_login.php");
//	exit();
//} 

$menu = 'listings';
	  require("db/opendb.php");
	  $user_id = $_GET["id"];
	  
	  //get user id
	  	$query = "select * from Users where Username='".$_SESSION["username"]."'";
		$result = mysql_query($query) or die ("SQL Error".mysql_error());
		$row=mysql_fetch_assoc($result);
		
		$user_query = "select u.*, s.ID, s.Parent_ID, s.Service from Users u left join Services s on s.ID = u.Service where u.ID='".$user_id."'";
		$user_result = mysql_query($user_query) or die ("SQL Error".mysql_error());
		$user_row=mysql_fetch_assoc($user_result);
	
		//require("db/closedb.php");
		
//require("db/opendb.php"); 
include('functions.php'); 
include('common/market_functions.php');

 
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<!--
<script type="text/javascript" src="js.js"></script>
<script type="text/javascript" src="ajax_notify.js"></script>-->
<title>Realivent.com - Real Estate News - User Profile</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="style.css" type="text/css">
<link rel="stylesheet" type="text/css" href="ajax_rating/stars_10.css" />
<link rel="stylesheet" type="text/css" href="accounts/listing_panel_css.css">
</head>

<body>
<table width="1000" border="0" cellspacing="0" cellpadding="0" align="center">
 <TR><TD><?php include('topnavagent.php'); ?></TD></TR>

  <tr>
    <td valign="top" style="height:300px;">
	<table width="100%"  border="0" cellspacing="0" cellpadding="0">
  <tr>
<td id=left_column width="75%" valign="top" align="left">
<?php include('user_profile_details_control.php'); ?>
<div id="invertedtabsline">&nbsp;</div>
<?php include('user_profile_control.php'); ?>
  <BR>
  <BR>
  
		<?php Get_Feature_Listings($user_id);?>

	 </td>
    <td width="20%" valign="top" align="left">
	<script type="text/javascript"><!--
google_ad_client = "pub-2163952417443596";
google_ad_width = 160;
google_ad_height = 600;
google_ad_format = "160x600_as";
google_ad_type = "text";
google_ad_channel ="";
google_color_border = "D7EAB0";
google_color_bg = "FFFFFF";
google_color_link = "0000FF";
google_color_text = "000000";
google_color_url = "008000";
//--></script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
	</td>
  </tr>
</table>

		
	</td>
  </tr>
 
</table>
<?php include('footer.php'); ?>
</body>
</html>
<?php
function Get_Feature_Listings($user)
{

	$mquery = "select p.* from PROPERTIES p inner join Prop_Owner_Con c on p.OID = c.Prop_OID where c.Owner = '".$user."' and LISTSTATUS = 'Active'";
	$mresult = mysql_query($mquery) or die ("SQL Error".mysql_error());
	if(mysql_num_rows($mresult))
	{
		?>
			<div style="color:#FF6600; font-size:20px; padding:20px 0px 0px 0px; ">Active Listings</div>
		<?
		while ($row = mysql_fetch_assoc($mresult))
		{
			$query = "select * from Listing_Images where Listing_ID = '".$row['OID']."' and Main_Photo = 1";
			$result = mysql_query($query) or die ("SQL Error".mysql_error());
			$lrow = mysql_fetch_assoc($result);
			?>
			<table width="100%"  border="0" cellspacing="0" cellpadding="0" style="padding-top:0px; ">
			<TR>
				<TD colspan="2"><DIV style="font-size:18px; color:#333333; padding:10px 0px 0px 0px; "><?php echo $row['STREETNUM']." ".$row['STREETNAME']." ".$row['STREETSUFFIX'].", ".$row['CITY']." ".$row['STATE'] ?></DIV>
				</TD>
			</TR>
			  <tr>
			  <?php 
			  if($lrow['Path']!='')
			  {
			  ?>
			  <td width=120><img style="border:1px solid black;" src=<?php echo $lrow['Server_Path']."t_".$lrow['Path'] ?>></td>
			  <?
			  }
			  else
			  {
			  ?>
				<td width=120 align="center" valign="top"><img style="border:1px solid black;" src=<?php echo "http://www.realivent.com/listing_images/nia_thumb.gif" ?>></td>
			<?
			}
			?>
				<td width="*" valign="top" style="font-size:12px;">
				<DIV style="padding-top:0px;">
				<div style="float:left; padding-right:10px;"><?php echo $row['BEDS'] ?> Beds | </div>
				<div style="float:left; padding-right:10px; "><?php echo $row['BATHSTOTAL'] ?> Baths | </div>
				<div style="float:left; padding-right:10px; "><?php echo number_format($row['SQFTTOTAL'], 0) ?> SQFT | </div>
				<div style="float:left; padding-right:10px; ">Covered Parking: <?php echo $row['PARKINGCOVERED'] ?> </div>
				</DIV>
				<div style="clear:left"></div>
				<BR>
				<div style="float:left; padding-right:10px;">Asking Price: $<?php echo number_format($row['LISTPRICE'], 0) ?></div>
				<BR>
				
				<div style="padding-right:10px;"><a href=listing_details.php?listing_id=<?php echo $row['OID'] ?>>More Details</a></div>
				
				</td>
			  </tr>
			</table>
	
			<?
		}
	}
	$mquery = "select p.* from PROPERTIES p inner join Prop_Owner_Con c on p.OID = c.Prop_OID where c.Owner = '".$user."' and LISTSTATUS = 'Pending'";
	$mresult = mysql_query($mquery) or die ("SQL Error".mysql_error());
	if(mysql_num_rows($mresult))
	{
		?>
			<div style="color:#FF6600; font-size:20px; padding:20px 0px 0px 0px;  ">Pending Listings</div>
		<?
		while ($row = mysql_fetch_assoc($mresult))
		{
			$query = "select * from Listing_Images where Listing_ID = '".$row['OID']."' and Main_Photo = 1";
			$result = mysql_query($query) or die ("SQL Error".mysql_error());
			$lrow = mysql_fetch_assoc($result);
			?>
			<table width="100%"  border="0" cellspacing="0" cellpadding="0" style="padding-top:0px; ">
			<TR>
				<TD colspan="2"><DIV style="font-size:18px; color:#333333; padding:10px 0px 5px 0px;  "><?php echo $row['STREETNUM']." ".$row['STREETNAME']." ".$row['STREETSUFFIX'].", ".$row['CITY']." ".$row['STATE'] ?></DIV></TD>
			</TR>
			  <tr>
				<td width=120><img style="border:1px solid black;" src=<?php echo $lrow['Server_Path']."t_".$lrow['Path'] ?>></td>
				<td width="*" valign="top" style="font-size:12px;">
				<DIV style="padding-top:5px;">
				<div style="float:left; padding-right:10px;"><?php echo $row['BEDS'] ?> Beds | </div>
				<div style="float:left; padding-right:10px; "><?php echo $row['BATHSTOTAL'] ?> Baths | </div>
				<div style="float:left; padding-right:10px; "><?php echo number_format($row['SQFTTOTAL'], 0) ?> SQFT | </div>
				<div style="float:left; padding-right:10px; ">Covered Parking: <?php echo $row['PARKINGCOVERED'] ?> </div>
				</DIV>
				<div style="clear:left"></div>
				<BR>
				<div style="float:left; padding-right:10px;">Asking Price: $<?php echo number_format($row['LISTPRICE'], 0) ?></div>
				<BR>
				
				<div style="padding-right:10px;"><a href=listing_details.php?listing_id=<?php echo $row['OID'] ?>>More Details</a></div>
				
				</td>
			  </tr>
			</table>
	
			<?
		}
	}
	$mquery = "select p.* from PROPERTIES p inner join Prop_Owner_Con c on p.OID = c.Prop_OID where c.Owner = '".$user."' and LISTSTATUS = 'Sold'";
	$mresult = mysql_query($mquery) or die ("SQL Error".mysql_error());
	if(mysql_num_rows($mresult))
	{
		?>
			<div style="color:#FF6600; font-size:20px; padding:20px 0px 0px 0px;  ">Sold Listings</div>
		<?
		while ($row = mysql_fetch_assoc($mresult))
		{
			$query = "select * from Listing_Images where Listing_ID = '".$row['OID']."' and Main_Photo = 1";
			$result = mysql_query($query) or die ("SQL Error".mysql_error());
			$lrow = mysql_fetch_assoc($result);
			?>
			<table width="100%"  border="0" cellspacing="0" cellpadding="0" style="padding-top:0px; ">
			<TR>
				<TD colspan="2"><DIV style="font-size:18px; color:#333333; padding:10px 0px 5px 0px;  "><?php echo $row['STREETNUM']." ".$row['STREETNAME']." ".$row['STREETSUFFIX'].", ".$row['CITY']." ".$row['STATE'] ?></DIV></TD>
			</TR>
			  <tr>
				<td width=120><img style="border:1px solid black;" src=<?php echo $lrow['Server_Path']."t_".$lrow['Path'] ?>></td>
				<td width="*" valign="top" style="font-size:12px;">
				<DIV style="padding-top:5px;">
				<div style="float:left; padding-right:10px;"><?php echo $row['BEDS'] ?> Beds | </div>
				<div style="float:left; padding-right:10px; "><?php echo $row['BATHSTOTAL'] ?> Baths | </div>
				<div style="float:left; padding-right:10px; "><?php echo number_format($row['SQFTTOTAL'], 0) ?> SQFT | </div>
				<div style="float:left; padding-right:10px; ">Covered Parking: <?php echo $row['PARKINGCOVERED'] ?> </div>
				</DIV>
				<div style="clear:left"></div>
				<BR>
				<div style="float:left; padding-right:10px;">Asking Price: $<?php echo number_format($row['LISTPRICE'], 0) ?></div>
				<BR>
				
				<div style="padding-right:10px;"><a href=listing_details.php?listing_id=<?php echo $row['OID'] ?>>More Details</a></div>
				
				</td>
			  </tr>
			</table>
	
			<?
		}
	}
}
?>


</table>
</body>
</html>
<?php require("db/closedb.php");?>
